package com.xbongbong.formula.qlexpress.operator.date;

import com.ql.util.express.Operator;
import com.xbongbong.formula.constant.Constant;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.util.DateTimeUtil;
import com.xbongbong.paas.toolbox.util.DateUtil;
import com.xbongbong.paas.toolbox.util.PaasDateUtil;
import com.xbongbong.paas.toolbox.util.RegexUtil;

import java.util.Objects;

/**
 * @author 吴峰
 * @version v1.0
 * @date 2019/8/9 9:51
 * @since v1.0
 */
public class OperatorNow extends Operator {


    public OperatorNow(String name){
        this.name = name;
    }

    public OperatorNow(String aliasName, String aName, String errorInfo){
        this.aliasName = aliasName;
        this.name = aName;
        this.errorInfo = errorInfo;
    }

    /**
     * 语法：NOW()
     * 说明：返回当前时间，精确到时分秒，格式为yyyy-MM-dd hh:mm:ss
     * 例如：显示当前操作的时间。
     */
    @Override
    public Object executeInner(Object[] list) {

        Long now = DateTimeUtil.getInt();
        String nowString = DateTimeUtil.getStringEpochSecond(now) + ":00";
        return DateTimeUtil.getInt(nowString, PaasDateUtil.SDF);
    }

}
